#include  <cstdio>
#include  <iostream>
#include  <string>
using namespace std;
int main(int argc, char *argv[])
{
	char c;
	int n,sum;
	scanf("%d",&n);
	string s;
	while( n-- )
	{
		cin >> s;
		for( int i = 0; i < 4 ; ++i )
		{
			sum = 0;
			for( int j = 0; j < 8 ; ++j )
			{
				sum <<= 1;
				if(s[i*8+j] == '1')
					sum++;
			}
			
			if(i == 0)
				printf("%d",sum);
			else
				printf(".%d",sum);
		}
		printf("\n");
	}
}
